<template>
  <div id="admin">
    <!-- 左边 -->
    <el-aside width=null>
      <admin-left :parent="this"></admin-left>
    </el-aside>

    <!-- 右边 -->
      <el-container>
          <el-header>
            <admin-head :parent="this"></admin-head>
          </el-header>

          <el-main>
            <router-view ref="children" style="overflow:auto" />
          </el-main>
        </el-container>
    <!-- 自定义弹窗 -->
    <!-- <tanchuang ref="tanchuang"></tanchuang> -->
  </div>
</template>

<script>
  import tanchuang from "../tanchuang/tanchuang.vue";
  import admin_head from "./head/head.vue";
  import admin_left from "./admin_left.vue";
  export default{
    name: "admin",
    components:{
      tanchuang,
      "admin-head":admin_head,
      "admin-left":admin_left
    },
    data(){
      return{
        collapse: false,
      }
    },
    methods:{

    },
    mounted(option) {
      // this.name = this.$refs.children.title_name;
      // console.log(this.name);
      //判断是否登录
      if(!localStorage.getItem("username") || localStorage.getItem("username") == "null"){
        this.$router.push({
            name:"login",
            //id=0未登录
            params:{id:0}
          });
      }

      //登陆成功提示
      if(this.$route.params.id == 1){
        this.$message.success("登陆成功");
        // this.$refs.tanchuang.dialog("登陆成功",true);
      }else if(this.$route.params.id == 2){
        // this.$refs.tanchuang.dialog("自动登录成功",true);
      }
    }
  }
</script>

<style>
  #admin{
    width: 100%;
    height: 100%;
    display: flex;
  }
  .admin_left{
    height: 100%;
    flex-shrink: 0;
  }
</style>
